package com.example.mapper;

import com.example.entity.History;
import com.example.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wanted
 * @since 2021-11-23
 */
@Repository
public interface UserMapper extends BaseMapper<User> {
        @Update("update pass set password = {password} where username={username}")
        public int updateUser(@PathVariable String username,@PathVariable String password);

        @Select("select name from user where id = #{id}")
            public String findName(int id);

        @Select("select * from user where name = #{name}")
        public List<User> findUser(String name);

        @Update("update user set temper = #{temper},health = #{health},statue=" +
                "#{statue} where name=#{name} and academic=#{academic}")
        int edit(String temper,String health,String statue,String name,String academic);

        @Insert("insert into user (name,academic,temper,health,statue) values" +
                "(#{name},#{academic},#{temper},#{health},#{statue})")
        int add(String name, String academic, String temper, String health, String statue);

        @Select("select * from history")
        List<History> list();

}
